package com.bootdo.backlist.service.impl;

import com.bootdo.backlist.converter.ConvertDomainUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.backlist.dao.InfoDao;
import com.bootdo.backlist.domain.InfoDO;
import com.bootdo.backlist.dto.InfoDTO;
import com.bootdo.backlist.service.InfoService;
import com.bootdo.backlist.converter.ConvertDomainUtils;
import com.bootdo.common.utils.R;



@Service
public class InfoServiceImpl implements InfoService {
	@Autowired
	private InfoDao infoDao;
	
	@Override
	public InfoDTO get(Integer id){
			InfoDO infoDO = infoDao.get(id);
			if (infoDO != null){
                return ConvertDomainUtils.convertObject(infoDO,InfoDTO.class);

            }
			return null;
	}
	
	@Override
	public List<InfoDTO> list(Map<String, Object> map){
		return ConvertDomainUtils.convertList(infoDao.list(map),InfoDTO.class);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return infoDao.count(map);
	}
	
	@Override
	public R save(InfoDTO info){
	    int i = infoDao.save(ConvertDomainUtils.convertObject(info,InfoDO.class));
        return R.result(i);
	}
	
	@Override
	public R update(InfoDTO info){
	    int i = infoDao.update(ConvertDomainUtils.convertObject(info,InfoDO.class));
		return R.result(i);
	}
	
	@Override
	public R remove(Integer id){
	    int i = infoDao.remove(id);
		return R.result(i);
	}
	
	@Override
	public R batchRemove(Integer[] ids){
	    int i = infoDao.batchRemove(ids);
		return R.result(i);
	}
	
}
